Skip to content

fix: derive workspace from devcontainer config, support subfolder opening#190

Merged
michidk merged 1 commit intomainfrom
fix/issue-82-config-subfolder
Mar 29, 2026
Merged

fix: derive workspace from devcontainer config, support subfolder opening#190
michidk merged 1 commit intomainfrom
fix/issue-82-config-subfolder

Conversation

@michidk
Copy link
Copy Markdown
Owner

@michidk michidk commented Mar 29, 2026

Summary

When --config points to a devcontainer.json, derive the workspace root from the config location instead of requiring the path argument to be the project root. If the path argument is a subdirectory of the derived workspace root, the relative path is appended to the container workspace folder in the VS Code URI.

Example — open a monorepo subfolder in a devcontainer:

# Project structure:
# /home/me/monorepo/.devcontainer/devcontainer.json
# /home/me/monorepo/frontend/
# /home/me/monorepo/backend/

vscli open --config /home/me/monorepo/.devcontainer/devcontainer.json /home/me/monorepo/backend
# Opens VS Code at /workspaces/monorepo/backend inside the container

Changes

  • main.rs: workspace_root_from_config() walks up from config path to find the .devcontainer parent, then uses its parent as workspace root. Extracts subfolder if path arg is a subdirectory of the root.
  • launch.rs: launch() accepts optional subfolder: Option<&Path> parameter, passed through to workspace.open().
  • workspace.rs: open() appends subfolder (with backslash normalization) to the container workspace path in the URI.
  • container.rs: Updated open() call site to pass None for subfolder.

Handles

  • Configs in .devcontainer/ folders (walks up to find it)
  • Nested configs like .devcontainer/python/devcontainer.json
  • Host path subfolders (extracted as relative path)
  • Normal usage without --config (no behavior change)
  • Windows backslash normalization in subfolder paths

Supersedes #185. Fixes #82.


Summary by cubic

Derives the workspace root from the devcontainer.json location when using --config and allows opening a subfolder inside the container if the given path is within that root. Fixes #82.

  • Bug Fixes
    • Walks up from the config to find the .devcontainer folder and uses its parent as the workspace root; supports nested configs.
    • If the provided path is a subdirectory, appends its relative path to the container workspace in the VS Code URI; normalizes Windows backslashes.
    • No behavior change when not using --config.

Written for commit 71f68cc. Summary will update on new commits.

…ning

When --config points to a devcontainer.json, derive the workspace root
from the config location (walking up to find .devcontainer parent).
If the path argument is a subdirectory of the workspace root, extract
the relative path and append it to the container workspace folder in
the VS Code URI, enabling subfolder opening within containers.

Fixes #82

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@michidk michidk merged commit 8b185d2 into main Mar 29, 2026
7 checks passed
@michidk michidk deleted the fix/issue-82-config-subfolder branch March 29, 2026 17:20
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/main.rs">

<violation number="1" location="src/main.rs:104">
P2: When `--config` resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so `vscli open --config rust-dev ~/projects/my-app` opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +104 to +108
let (workspace_path, subfolder) = if let Some(ref config) = resolved_config {
workspace_root_from_config(config, &path)?
} else {
(path.clone(), None)
};
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When --config resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so vscli open --config rust-dev ~/projects/my-app opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/main.rs, line 104:

<comment>When `--config` resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so `vscli open --config rust-dev ~/projects/my-app` opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.</comment>

<file context>
@@ -70,28 +95,34 @@ fn main() -> Result<()> {
                 .as_ref()
                 .and_then(|p| config_store::config_name_from_path(p, &config_store));
 
+            let (workspace_path, subfolder) = if let Some(ref config) = resolved_config {
+                workspace_root_from_config(config, &path)?
+            } else {
</file context>
Suggested change
let (workspace_path, subfolder) = if let Some(ref config) = resolved_config {
workspace_root_from_config(config, &path)?
} else {
(path.clone(), None)
};
let (workspace_path, subfolder) = if let Some(ref config) = resolved_config {
let (root, sub) = workspace_root_from_config(config, &path)?;
let path_abs = path.canonicalize().unwrap_or_else(|_| path.clone());
if path_abs.starts_with(&root) {
(root, sub)
} else {
(path.clone(), None)
}
} else {
(path.clone(), None)
};
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specifying a custom container path does not work.

1 participant